/*

slask! 

if ( irinori === undefined ) 
{
	var irinori = {};
}

irinori.Random = function(a_seed) 
{
    //Private variables
    var m_seed;

    //public variables
    this.m_N = 624;
    this.m_M = 397;

    this.m_matrixA = 2567483615; //0x9908b0df
    this.m_upperMask = 2147483648; //0x80000000
    this.m_lowerMask = 2147483647; //0x7fffffff

    //Used when bitshifting the 7 bits
    this.m_temperingMaskB = 2636928640;//0x9d2c5680
    //Used when bitshifting 15 bits
    this.m_temperingMaskC = 4022730752;//0xefc60000;

    this.m_mt = {};
    this.m_mti;

    irinori.Random.m_mag01[0] = 0;
    irinori.Random.m_mag01[1] = this.m_matrixA;
    
    if (a_seed === undefined)
    {
        throw "Need a seed";
    }
    else
    {
        m_seed = a_seed;
    }
    
    

    /*functions
    
    this.init(m_seed);
    
}

irinori.Random.m_mag01 = {};

irinori.Random.prototype.init = function(a_seed)
{
    /*
    _mt[0] = seed & 0xffffffffU;

            for (_mti = 1; _mti < N; _mti++)
            {
                _mt[_mti] = (uint)(1812433253U * (_mt[_mti - 1] ^ (_mt[_mti - 1] >> 30)) + _mti);
                // See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. 
                // In the previous versions, MSBs of the seed affect   
                // only MSBs of the array _mt[].                        
                // 2002/01/09 modified by Makoto Matsumoto             
                _mt[_mti] &= 0xffffffffU;
                // for >32 bit machines
            }
    
    this.m_mt[0] = a_seed & 4294967295; //0xffffffff

    for (this.m_mti = 1; this.m_mti < this.N; this.m_mti++) 
    {
        //this.m_mt[this.m_mti] = (
    }
}
*/

if (irinori === undefined)
{
    window.irinori = {};
}

if (irinori.Testing === undefined)
{
   window.irinori.Testing = {}
}

irinori.Testing.PRNGTest = function()
{
    var m = new irinori.Random(100);
    var randomNumber;
    var i;
    var m_numbers = {};
        
    for (i = 0; i < 10000; i++) 
    {
        randomNumber = m.Next(0, 10);
        //console.log(randomNumber);

        if (m_numbers[randomNumber] === undefined)
        {
            m_numbers[randomNumber] = 1;
        }
        else
        {
            m_numbers[randomNumber]++;
        }            
    }
        
    for (i = 0; i < 10; i++) 
    {
        console.log(i + " : " + m_numbers[i] );
    }
}

irinori.Testing.PRNGTest();

        